const {
  WINTER_START_DATE,
  SUMMER_START_DATE
} = require('./config');
const dayjs = require('dayjs');
/**
 * 课表工具函数
 */
function calcDefault() {
  let nowDate = dayjs();
  let year = dayjs().year();
  /**获取当前月份 */
  let month = dayjs().month() + 1;
  if (month >= 9 && month <= 2) {
    let startDate = year + '-' + SUMMER_START_DAY;
    let weekDiff = nowDate.diff(startDate, 'weeks');
    return {
      week: weekDiff + 1,
      semester: 1,
      studyYear: parseInt(year),
      startDate
    }

  } else {
    let startDate = year + '-' + WINTER_START_DATE;
    let weekDiff = nowDate.diff(startDate, 'weeks');
    return {
      week: weekDiff + 1,
      semester: 2,
      studyYear: parseInt(year) - 1,
      startDate
    }
  }
}
module.exports = {
  calcDefault
}